package com.ruoyi.law.factory.inter.impl;

import cn.hutool.core.map.MapUtil;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.law.annotation.ReturnStrategy;
import com.ruoyi.law.enums.ReturnStrategyEnum;
import com.ruoyi.law.factory.inter.DataHandler;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 一定时间内只能执行一次
 *
 * @author lie
 * @date 2023/11/15
 */
@ReturnStrategy(returnStrategy = ReturnStrategyEnum.ONCE)
@Service
public class OnceStrategyHandler implements DataHandler {


    @Override
    public Object handleData(Map<String, Object> params) {
        String message = MapUtil.getStr(params, "message");
        throw new ServiceException(message);
    }
}
